'''
Created on 6 mai 2010

@author: philip
'''

import logging 
from models import Explorer
from django.core.exceptions import ObjectDoesNotExist

class PeopleRepository():
    def __init__(self):
        pass
    
    def getOrAddExplorer(self,userId):
        """
            gets an explorer with this userId 
            (creates new explorer if needed
             new explorer IS NOT inserted into database 
             automatically
            )
            @return: Explorer django model  
        """
        logging.debug("geting explorer for user: %s" % userId)
        explorer = None

        try:
            explorer = Explorer.objects.get(userId=userId)
        except ObjectDoesNotExist:
            logging.debug("given user is not an explorer, fixing...")
            explorer = Explorer(userId=userId)
        return explorer